<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/locale/easyui-lang-zh_CN.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/js/add-tab.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/css/common.css" />

	<script type="text/javascript">
	$.extend($.fn.validatebox.defaults.rules, {
        
        mobile: {
        validator: function (value) {
            var reg = /^1[3|4|5|8|9]\d{9}$/;
            return reg.test(value);
        },
        message: '输入手机号码格式不准确.'
       },
        
        QQ:{
            validator: function (value, param) {
                return /^[1-9]\d{4,10}$/.test(value);
            },
            message: 'QQ号码不正确'
        },
        equalTo: {
            validator: function (value, param) {
            return value== $(param[0]).val();
            },
            message: '两次输入的字符不一至'
        },
        idcard : {
            validator : function(value) {
                return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value);
            },
            message : '身份证号码格式不正确'
        },
        phone : {
        validator : function(value) {
            return /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i.test(value);
        },
        message : '格式不正确,请使用下面格式:020-88888888'
        },
        integer : {
        validator : function(value) {
            return /^[+]?[0-9]+\d*$/i.test(value);
        },
        message : '请输入数字'
        },
        oldpassword:{
        validator: function(value){  
                var flag;
                    $.ajax({
                            type: 'POST', 
                            url: '__APP__/User/judgePassword',
                            data:{employe_old_password:value},
                            async:false,
                            success: function(data) {
                                if(data=='ok') {
                                    flag = true;
                                }else{
                                    flag = false;
                                }
                            }
                     });
                  return flag;
            },
           message: '密码错误，请输入正确的密码！'
        }
    });


	$(function(){
		$('#addemployefrm').form({
			url:'__URL__/changePasswordPost',
		    onSubmit:function(){
		        return $(this).form('validate');
		    },
		    success:function(data){
		    	if(data=='ok'){
		    		$.messager.alert('提醒', '保存成功!', 'info');
		    	}
		    	if(data=='no'){
		    		$.messager.alert('提醒','您还没有修改!','info');
		    	}
		    }
		});
	})



	$(function(){
		$('#uiform input').each(function () {
		    if ($(this).attr('required') || $(this).attr('validType'))
		        $(this).validatebox();
		})


		$('.employe_old_password').blur(function(){
			//alert('err');
		})
	});

    KindEditor.ready(function(K) {
        var editor = K.editor({
            allowFileManager : true
        });
        K('#image3').click(function() {
            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    showRemote : false,
                    imageUrl : K('#url3').val(),
                    clickFn : function(url, title, width, height, border, align) {
                        K('#url3').val(url);
                        K('.photo').attr("src",url);
                        editor.hideDialog();
                    }
                });
            });
        });
    });
    </script>

</head>
<body>
<form id="addemployefrm" method="post">
<div id="uiform">
	<div  class="easyui-panel" title="密码修改" style="width:650px;background:#fafafa;" data-options="headerCls:'title',iconCls:'icon-change'">
		<table>
			<tr>
				<td>原始密码：</td>
				<td><input type="password" class="employe_old_password easyui-validatebox" data-options="validType:['oldpassword','length[6,30]'],required:true"/></td>
			</tr>
			<div style="display:none;">
				<tr>
					<td>新密码：</td>
					<td><input type="password" class="employe_password easyui-validatebox" name="employe_password" type="password" data-options="validType:['length[6,30]'],required:true"/></td>
				</tr>
				<tr>
					<td>确认密码：</td>
					<td><input type="password" class="employe_password_true easyui-validatebox" name="employe_password_true" type="password" validType="equalTo['.employe_password']" data-options="required:true"/></td>
				</tr>
				<tr>
					<td colspan="2" style="text-align: center;"><input type="submit" value="保存"/></td>
				</tr>
			</div>
		</table>
	</div>
</div>
</form>
</body>
</html>